package com.myweb.action.sys;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import com.myweb.action.BaseAction;
import com.myweb.entity.sys.SysUser;
import com.myweb.service.sys.ISysMenuService;
import com.myweb.service.sys.ISysUserService;
import com.myweb.util.DateUtil;

/**
 * 
 * @TODO 用户处理
 * @author roye
 * @date Apr 25, 2013 11:18:40 AM
 * @version V1.0
 */
@SuppressWarnings("serial")
@Controller("com.myweb.sys.userAct")
public class SysUserAction extends BaseAction{
	
	
	@Autowired
	private ISysUserService isysUserService;
	
	@Autowired
	private ISysMenuService isysMenuService;
	
	/**
	 * 
	 * @todo 查询用户列表
	 * @author roye
	 * @date Apr 25, 2013 11:22:34 AM
	 * @param   
	 * @return String   
	 * @throws
	 */
	public String getUserList() throws IOException{
		
		Map<String, Object> queryParamMap = new HashMap<String, Object>();
		int count = isysUserService.querySysUserCount(queryParamMap);
		queryParamMap.put("start_row", this.start_row);  
		queryParamMap.put("page_size", this.page_size); 
		List<SysUser> dataList = isysUserService.querySysUserList(queryParamMap);
		JSONArray jsonArray = new JSONArray();  
        JSONObject jsonobj = new JSONObject(); 
		for (SysUser user :dataList ) {
			jsonobj.put("id", user.getUserId());  
            jsonobj.put("userName", user.getUserName());  
            jsonobj.put("loginName", user.getLoginName());  
            jsonobj.put("createTime", DateUtil.getDateFormat(user.getCreateTime(), "yyyy-MM-dd"));  
            jsonArray.add(jsonobj);  
		}
		this.writeJson(jsonArray, count);
		return null;
	}
	
}
